﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    /// <summary>
    /// 
    /// </summary>
    public class Tiro
    {
        /// <summary>
        /// 
        /// </summary>
        static Texture2D textura;

        /// <summary>
        /// 
        /// </summary>
        Vector2 velocidade = new Vector2(0, 5);

        /// <summary>
        /// 
        /// </summary>
        int direcao = -1;
        
        /// <summary>
        /// 
        /// </summary>
        Vector2 posicao;

        /// <summary>
        /// 
        /// </summary>
        Rectangle recColisao;

        public bool visivel;

        /// <summary>
        /// 
        /// </summary>
        public Rectangle RecColisao
        {
            get
            {
                return recColisao;
            }
            set
            {
                recColisao = value;
            }
        }

        public bool trocaTiro = false;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="textura"></param>
        /// <param name="posicao"></param>
        public Tiro(Texture2D textura, Vector2 posicao)
        {
            visivel = true;
            Tiro.textura = textura;
            this.posicao = posicao;
            this.RecColisao = new Rectangle((int)posicao.X, (int)posicao.Y, 10, 10);//tamanho...
            //direcao e velocidade...
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            posicao.Y += direcao * velocidade.Y;
            this.RecColisao = new Rectangle((int)posicao.X, (int)posicao.Y, 10, 10);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="spriteBatch"></param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (visivel)
            spriteBatch.Draw(textura, recColisao, Color.White);

            if (trocaTiro & visivel)
            {
                spriteBatch.Draw(textura, recColisao, Color.White);
                spriteBatch.Draw(textura, new Rectangle(recColisao.X - 50, recColisao.Y, recColisao.Width, recColisao.Height), recColisao, Color.White);
            }
        }

      
    }
}
